Day09 主要在介紹各種 console 的用法
console.log("Hello")
console.log("Hello I am a %s string!", "💩")
console.log(
"%c I am some great text",
"font-size:50px; background:red; text-shadow: 10px 10px 0 blue"
),
console.warn("OH NOOO")
console.error("Shit!")
console.info("Crocodiles eat 3-4 people per year")
const p = document.querySelector("p");
console.assert(p?.classList.contains("ouch"), "That is wrong!");
console.clear()
const p = document.querySelector("p");
console.dir(p);
const dogs = [
{ name: "Snickers", age: 2 },
{ name: "Hugo", age: 8 },
];
dogs.forEach((dog) => {
console.groupCollapsed(`${dog.name}`);
console.log(`This is ${dog.name}`);
console.log(`${dog.name} is ${dog.age} years old`);
console.log(`${dog.name} is ${dog.age * 7} dog years old`);
console.groupEnd();
});
console.count("Wes");
console.count("Steve");
console.count("Wes");
console.count("Steve");
console.count("Wes");
console.time("fetching data");
fetch("https://api.github.com/users/wesbos")
.then((data) => data.json())
.then((data) => {
console.timeEnd("fetching data");
console.log(data);
});
const dogs = [
{ name: "Snickers", age: 2 },
{ name: "Hugo", age: 8 },
];
console.table(dogs);